/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vera.hibernate.dao;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import vera.hibernate.entity.Messengers;
import vera.hibernate.util.HibernateUtil;

/**
 *
 * @author vgncr35g
 */
public class MessengersDAO extends EntityDAO{
    public MessengersDAO()
    {
        
    }
    
    public List<Messengers> getMessengers()
    {
        Session s = HibernateUtil.openSession();
        Query q = s.getNamedQuery("getAllMessengers");
        List<Messengers> messengers = q.list();
        s.close();
        return messengers;
    }
    
    public Messengers getMessenger(int msgrCd)
    {
        Session s = HibernateUtil.openSession();
        Query q = s.getNamedQuery("getMessenger");
        q.setInteger("msgrCd", msgrCd);
        Messengers messenger = (Messengers) q.uniqueResult();
        s.close();
        return messenger;
    }
    
    public void deleteMessenger(int msgrCd)
    {
        deleteEntity(getMessenger(msgrCd));
    }
    
}
